/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pi2.osr.ejb.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.persistence.GenerationType;
import javax.persistence.SequenceGenerator;
import javax.persistence.GeneratedValue;
/**
 *
 * @author admin
 */
@Entity
@Table(catalog = "", schema = "P09713_2_10")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tipodocumento.findAll", query = "SELECT t FROM Tipodocumento t"),
    @NamedQuery(name = "Tipodocumento.findByIdtipodocumento", query = "SELECT t FROM Tipodocumento t WHERE t.idtipodocumento = :idtipodocumento"),
    @NamedQuery(name = "Tipodocumento.findByTipo", query = "SELECT t FROM Tipodocumento t WHERE t.tipo = :tipo")})
public class Tipodocumento implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @SequenceGenerator(name="TIPODOCUMENTO_IDTIPODOCUMENTO_GENERATOR", sequenceName="TIPODOCUMENTO_SEQ", allocationSize=1)
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="TIPODOCUMENTO_IDTIPODOCUMENTO_GENERATOR")
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false, precision = 0, scale = -127)
    private BigDecimal idtipodocumento;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(nullable = false, length = 50)
    private String tipo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idtipodocumento", fetch = FetchType.LAZY)
    private List<Usuario> usuarioList;

    public Tipodocumento() {
    }

    public Tipodocumento(BigDecimal idtipodocumento) {
        this.idtipodocumento = idtipodocumento;
    }

    public Tipodocumento(BigDecimal idtipodocumento, String tipo) {
        this.idtipodocumento = idtipodocumento;
        this.tipo = tipo;
    }

    public BigDecimal getIdtipodocumento() {
        return idtipodocumento;
    }

    public void setIdtipodocumento(BigDecimal idtipodocumento) {
        this.idtipodocumento = idtipodocumento;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    @XmlTransient
    public List<Usuario> getUsuarioList() {
        return usuarioList;
    }

    public void setUsuarioList(List<Usuario> usuarioList) {
        this.usuarioList = usuarioList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idtipodocumento != null ? idtipodocumento.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tipodocumento)) {
            return false;
        }
        Tipodocumento other = (Tipodocumento) object;
        if ((this.idtipodocumento == null && other.idtipodocumento != null) || (this.idtipodocumento != null && !this.idtipodocumento.equals(other.idtipodocumento))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.pi2.osr.ejb.entites.Tipodocumento[ idtipodocumento=" + idtipodocumento + " ]";
    }
    
}
